home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions BackAxon component
-
- #include "NSDLL.h"
-
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackFuzzyAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *error, // Pointer to the sensitivity vector
- NSFloat *param, // Pointer to the layer of parameters for the MFs
- int paramIndex, // Index of the MF parameter
- int winnerIndex,// Index of the winning MF
- NSFloat winnerVal, // Value of the winning Input
- NSFloat *returnVal // Return value
- )
- {
- NSFloat b;
- NSFloat c;
- NSFloat tmp1;
- NSFloat tmp2;
- NSFloat denom;
- NSFloat a = *(param + winnerIndex);
- if (a == 0.0f)
- *returnVal = 0.0f;
- b = *(param + winnerIndex + 1);
- c = *(param + winnerIndex + 2);
- tmp1 = (winnerVal - c)/a;
- tmp2 = tmp1 == 0 ? 0 : (NSFloat)pow(tmp1*tmp1, b);
- denom = (1 + tmp2)*(1 + tmp2);
- if (paramIndex == winnerIndex)
- *returnVal = (2*b*tmp2/(a*denom));
- if (paramIndex == (winnerIndex + 1)) {
- if (tmp1 == 0)
- *returnVal = 0.0f;
- else
- *returnVal = ((NSFloat)-log(tmp1*tmp1)*tmp2/denom);
- }
- if (paramIndex == (winnerIndex + 2)) {
- if (winnerVal == c)
- *returnVal = 0.0f;
- else
- *returnVal = (2*b*tmp2/((winnerVal - c)*(denom)));
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocBackFuzzyAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeBackFuzzyAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */